
TRIGGER PROCEDURE FOR DELETE OF PI_MSTR.

{mfdeclre.i }
define new shared work-table wf_old_pi_mstr like pi_mstr.

HK:
do:
    if can-find(first dt_mstr where dt_table = "pi_mstr" and dt_type = "SYNC") then
        run CreateSyncFlag(input "DEL", input recid(pi_mstr), input "pi_mstr").

    if not can-find ( first dt_mstr where dt_table = "pi_mstr" and dt_type = "DEL" ) then leave HK.
    
    if not can-find ( first wf_old_pi_mstr ) then do:
        create wf_old_pi_mstr.
        if recid(wf_old_pi_mstr)= -1 then .
    end.
    
    buffer-copy pi_mstr to wf_old_pi_mstr no-error.

    for first dt_mstr no-lock where dt_table = "pi_mstr" and dt_type = "DEL" :
    
    	run CreateDthist(input dt_table, input dt_field, input dt_type, input "", input "", 
        	input recid(pi_mstr), input pi_mstr.pi_list, input pi_mstr.pi_part_code, input pi_mstr.pi_cs_code, input pi_mstr.pi_part_type,
        	input pi_mstr.pi_cs_type, input pi_mstr.pi_curr, input pi_mstr.pi_um, input string(pi_mstr.pi_start)) .
        	
    end.
end.

{hkdttrans.i}
